home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / thor / golded / uuencode.ged < prev   
Text File  |  1996-11-10  |  4KB  |  114 lines

  1. /* UUEncode.ged by Troels Walsted Hansen <troelsh@powertech.no>
  2. ** $VER: UUEncode.ged v1.20 (11.08.95)
  3. **
  4. ** An ARexx script that uuencodes a file and imports it into the
  5. ** GoldED you are currently using. Unless the file is already
  6. ** archived this script will optionally do it for you (using LhA).
  7. **
  8. ** Utilises LhA by Stefan Boberg and either of the following:
  9. **    · UUFast v1.25 by Jørn Halonen
  10. **    · uuIn v1.03 by Nicolas Dade
  11. **    · UUxT v3.1 by Asher Feldman
  12. **
  13. ** Hitory
  14. ** ¯¯¯¯¯¯
  15. ** UUEncode.ged v1.10 (09.06.95)
  16. **      · uses GoldED's requester-commands instead of THOR's
  17. **
  18. ** UUEncode.ged v1.20 (11.08.95)
  19. **      · added the uuprogpath user variable
  20. **      · now disregards case in uudecoder variable setting
  21. */
  22.  
  23. /* some user variables. edit to your hearts content */
  24.  
  25. tmpdir = "T:"        /* Work dir for the encoding        */
  26. uuencoder = "uuin"    /* may be: "uuin", "uufast" or "uuxt"    */
  27. uuprogpath = "C:"    /* Path to your uuencoder. This    path    */
  28.             /* MUST end with either ':' or '/'.    */
  29.  
  30. /* do NOT edit below here unless you know what you're doing :-) */
  31.  
  32. options results
  33.  
  34. /* needs GoldED and bbsread.library functions */
  35.  
  36. if(substr(address(),1,6) ~= "GOLDED") then
  37. do
  38.     say "This script should only be started from inside GoldED."
  39.     exit 20
  40. end
  41. else gedport = address()
  42.  
  43. if ~show('p', 'BBSREAD') then
  44. do
  45.     address command
  46.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  47.         "WaitForPort BBSREAD"
  48. end
  49.  
  50. /* get filename */
  51.  
  52. address(bbsread)
  53. GETGLOBALDATA STEM GLOBALDATA
  54.  
  55. address(gedport)
  56. REQUEST TITLE '"Select file to encode:"' FILE PATH '"'GLOBALDATA.UPLOADPATH'"' MASK '"#?"' VAR filetoencode
  57. if(rc ~= 0) then exit
  58.  
  59. lastchar = right(filetoencode,1)
  60.  
  61. if(lastchar = "/" | lastchar = ":" | filetoencode = "") then
  62. do
  63.     REQUEST BODY '"No file selected!"' BUTTON '"_Ok"' TITLE '"Error"' VAR result
  64.     signal exit
  65. end
  66.  
  67. posi = lastpos("/",FileToEncode)
  68. if(posi = 0) then posi = lastpos(":",FileToEncode)
  69. WithoutPath = substr(FileToEncode,posi+1)
  70.  
  71. /* if file isn't LhA'ed -- do it ourselves */
  72.  
  73. extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
  74.  
  75. if~(extension = "LHA" | extension = "LZH") then
  76. do
  77.     REQUEST BODY '"Do you want to LhA the file?"' BUTTON '"_Yes|_No"' TITLE '"UUEncode.ged"' VAR result
  78.     if(result) then
  79.     do
  80.         address command "LhA >nil: -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
  81.  
  82.         if(rc ~= 0) then REQUEST BODY '"LhA''ing did not succeed."' BUTTON '"_Ok"' TITLE '"UUEncode.ged"' VAR result
  83.         else FileToEncode = tmpdir||WithoutPath||".lha"
  84.     end
  85. end
  86.  
  87. select
  88.     when(upper(uuencoder) = 'UUFAST')    then cmd = uuprogpath || 'UUFast >nil: ' || '"' || filetoencode || '"' || " TO " || tmpdir || "Message.uu E"
  89.     when(upper(uuencoder) = 'UUIN')        then cmd = uuprogpath || 'uuIn >nil: INFILE=' || '"' || filetoencode || '"' || " OUTFILE=" || tmpdir || "Message.uu"
  90.     when(upper(uuencoder) = 'UUXT')        then cmd = uuprogpath || 'UUxT >nil: a ' || tmpdir || 'Message.uu ' || '"'filetoencode'"'
  91.     otherwise
  92.     do
  93.         REQUEST BODY '"UUEncoder not configured correctly."' BUTTON '"_Ok"' TITLE '"UUEncode.ged"' VAR result
  94.         signal exit
  95.     end
  96. end
  97. address command cmd
  98.  
  99. if ~exists(tmpdir"Message.uu") then
  100. do
  101.     REQUEST BODY '"Something went wrong during uuencoding."' BUTTON '"_Ok"' TITLE '"UUEncode.ged"' VAR result
  102.     signal exit
  103. end
  104.  
  105. address(gedport)
  106. OPEN NAME '"' || tmpdir || 'Message.uu' || '"' FAST INSERT
  107.  
  108. /* cleanup and exit */
  109.  
  110. exit:
  111.     if(exists(tmpdir || WithoutPath || ".lha")) then address command 'delete >nil: ' || '"' || tmpdir || WithoutPath || '.lha' || '"'
  112.     if(exists(tmpdir || "Message.uu")) then address command 'delete >nil: ' || tmpdir || 'Message.uu'
  113.     exit
  114.